<?php
namespace App\Http\Service;

require_once "../app/Lib/qiniu/autoload.php";

use Qiniu\Auth;

class QiniuService {

    /**
     * 七牛云访问秘钥
     * @author zx
     * @var string
     */
    private $_accessKey;

    /**
     * 七牛云私密秘钥
     * @author zx
     * @var string
     */
    private $_secretKey;

    /**
     * 七牛云存储空间
     * @author zx
     * @var string
     */
    private $_bucket;

    public function __construct()
    {
        /**
         * 初始化秘钥
         */
        $this->_accessKey = config("config.qiniu.accessKey");
        $this->_secretKey = config("config.qiniu.secretKey");
        $this->_bucket = config("config.qiniu.imge_bucket");
    }

    /**
     * 获取文件上传token
     */
    public function getToken()
    {
        $auth = new Auth($this->_accessKey, $this->_secretKey);

        $token = $auth->uploadToken($this->_bucket);

        return $token;
    }

}